<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:sisguia="http://guiav6.com.br/sisguia"
	template="/pages/template/layoutBusca.xhtml">

<ui:define name="body">

	<h:form prependId="false" id="form">
	
		<h:panelGroup layout="block" id="pnlDetalheAnuncio">
		
			<h:panelGroup layout="block" styleClass="anuncio">
			
				<h:panelGroup layout="block" styleClass="painelEsquerdo">
					<h:graphicImage value="/img/mini_icon_restaurante.png" />
				</h:panelGroup>
				
				<h:panelGroup layout="block" styleClass="painelCentro">
					<h:panelGroup layout="block" styleClass="dado">
						<h:outputText value="#{anuncioAction.empresa.nomeFantasia}" />
					</h:panelGroup>
					<h:panelGroup layout="block" styleClass="dado">
						<h:outputText value="#{anuncioAction.empresa.endereco.logradouro}" />
					</h:panelGroup>
					<h:panelGroup layout="block" styleClass="dado">
						<h:outputText value="#{anuncioAction.empresa.endereco.bairro.nome}, DF |  #{anuncioAction.empresa.endereco.cep}" />
					</h:panelGroup>
					<ui:repeat var="tel" value="#{anuncioAction.empresa.telefoneList}">
						<h:panelGroup layout="block" styleClass="dado">
							<h:outputText value="(#{tel.ddd}) #{tel.telefone}" />
						</h:panelGroup>
					</ui:repeat>
					<ui:repeat var="se" value="#{anuncioAction.servicoEspecialidadeList}">
						<h:panelGroup layout="block" styleClass="dado">
							<h:outputText value="#{se.servico}" />
							<h:outputText value=" (" rendered="#{not empty se.especialidades}" />
							<ui:repeat varStatus="st" var="especialidade" value="#{se.especialidades}">
								<h:outputText value="#{especialidade}" />
								<h:outputText value=", " rendered="#{st.last == false}"/>
							</ui:repeat>
							<h:outputText value=")" rendered="#{not empty se.especialidades}" />
						</h:panelGroup>
					</ui:repeat>
					<h:panelGroup layout="block" styleClass="dado">
						<h:outputLink value="#{anuncioAction.empresa.site}" target="_blank">
							<h:graphicImage value="/img/btn_site.png" />
						</h:outputLink>
					</h:panelGroup>
				</h:panelGroup>
				
				<h:panelGroup layout="block" styleClass="painelDireito">
					<div style="background-image: url('#{request.contextPath}#{anuncioAction.empresa.pathMapa}'); width: 500px; height: 352px; position: relative;">
						<ui:repeat var="bloco" value="#{sisguia:mapToList(anuncioAction.blocoMap)}">
							<div>
								<span>
									<p:commandLink actionListener="#{anuncioAction.findEmpresasByBloco}" ajax="true" update=":form:pnlDetalheAnuncio" oncomplete="wdgBloco.show();">
										<p:graphicImage value="/img/bloco_selecao.png" style="position: absolute; top: #{bloco.value[0]}px; left: #{bloco.value[1]}px;" />
										<p:graphicImage value="/img/bloco_selecionado.png" style="position: absolute; top: #{bloco.value[0]}px; left: #{bloco.value[1]}px;" rendered="#{anuncioAction.empresa.endereco.bloco == bloco.key}" />
										<f:param name="bloco" value="#{bloco.key}"/>
									</p:commandLink>
								</span>
							</div>
						</ui:repeat>
					</div>
				</h:panelGroup>
				
				<p:dialog id="panelDetalheBloco" resizable="false" width="540" height="390" header="#{msg['label.estabelecimentos']}" showEffect="clip" widgetVar="wdgBloco">
					<h:panelGroup layout="block">
						<ui:repeat var="empresa" value="#{anuncioAction.empresaBlocoList}">
							<h:panelGroup layout="block" styleClass="dado">
								<h:commandLink action="#{anuncioAction.detalharAnuncio}" value="#{empresa.nomeFantasia}" >
									<f:param name="idEmpresa" value="#{empresa.id}" />
								</h:commandLink>
							</h:panelGroup>
						</ui:repeat>						
					</h:panelGroup>				
				</p:dialog>
				
			</h:panelGroup>
			
			<p:spacer height="20" />
		
		</h:panelGroup>
	
	</h:form>
	
</ui:define>

</ui:composition>